<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="actionParameters" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{actionParametersHome.managed ? 'Edit' : 'Add'} Action parameters</f:facet>




            <s:decorate id="parameterNameField" template="layout/edit.xhtml">
                <ui:define name="label">Parameter name</ui:define>
                <h:inputText id="parameterName"
                       required="true"
                           size="30"
                      maxlength="30"
                          value="#{actionParametersHome.instance.parameterName}">
                    <a:support event="onblur" reRender="parameterNameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="parameterValueField" template="layout/edit.xhtml">
                <ui:define name="label">Parameter value</ui:define>
                <h:inputTextarea id="parameterValue"
                               cols="80"
                               rows="3"
                           required="true"
                              value="#{actionParametersHome.instance.parameterValue}"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{actionParametersHome.persist}"
                       disabled="#{!actionParametersHome.wired}"
                       rendered="#{!actionParametersHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{actionParametersHome.update}"
                       rendered="#{actionParametersHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{actionParametersHome.remove}"
                      immediate="true"
                       rendered="#{actionParametersHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/ActionParameters.xhtml"
                rendered="#{actionParametersHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty actionParametersFrom ? 'ActionParametersList' : actionParametersFrom}.xhtml"
                rendered="#{!actionParametersHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Device actions *" labelClass="required">
    <div class="association" id="deviceActionsParent">

        <h:outputText value="There is no deviceActions associated with this actionParameters."
                   rendered="#{actionParametersHome.instance.deviceActions == null}"/>

        <rich:dataTable var="_deviceActions"
                   value="#{actionParametersHome.instance.deviceActions}"
                rendered="#{actionParametersHome.instance.deviceActions != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="deviceActionsTable">
            <h:column>
                <f:facet name="header">Device actions id</f:facet>
                <h:outputText value="#{_deviceActions.deviceActionsId}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Device device id</f:facet>
                <h:outputText value="#{_deviceActions.device.deviceId}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Action type</f:facet>
                <h:outputText value="#{_deviceActions.actionType}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Name</f:facet>
                <h:outputText value="#{_deviceActions.name}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{actionParametersHome.instance.deviceActions != null ? 'changeParent' : 'selectParent'}" value="#{actionParametersHome.instance.deviceActions != null ? 'Change' : 'Select'} deviceActions"
                       view="/DeviceActionsList.xhtml">
                <f:param name="from" value="ActionParametersEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
